//
//  OosTagParser.m
//  oos4ios
//
//  Created by Pablo Gonzalez on 4/13/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import "OosTagParser.h"
#import <oos4ios/Model/OosTag.h>
#import "../GData/Common/Elements/GDataCategory.h"
#import "../GData/Common/Optional/Introspection/GDataAtomCategoryGroup.h"

@implementation OosTagParser

static OosTagParser *instance;

+ (OosTagParser *)instance
{
    if (!instance) {
        instance = [[OosTagParser alloc] init];
    }
    return instance;
}

- (NSArray *)parseCategories:(GDataAtomCategoryGroup *)categoryGroup
{
    NSMutableArray *result = [NSMutableArray array];
    OosTag *tag;
    for (GDataCategory *category in [categoryGroup categories]) {
        NSString *term = [category term];
        tag = [OosTag tagFromTerm: term];
        tag.label = [category term];
        [result addObject:tag];
    }
    return result;
}

@end
